<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Serial I/O</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="edit68k.css" rel="stylesheet" type="text/css">
</head>

<body class="text">
<p class="heading">Sim68K Serial I/O<hr noshade></p>
<p>TRAP #15 is used for I/O. &nbsp;Put the task number in lower 8 bits of D0.</p>

<p>The success of the Serial I/O calls is returned in
D0.W as follows:<br>
&nbsp;&nbsp;&nbsp; 0 = Success<br>
&nbsp;&nbsp;&nbsp; 1 = Invalid port identifier (PID)<br>
&nbsp;&nbsp;&nbsp; 2 = Error<br>
&nbsp;&nbsp;&nbsp; 3 = Port not initialized (Tasks 41, 42, 43 only)<br>
&nbsp;&nbsp;&nbsp; 4 = Timeout (Tasks 42, 43 only)<br>
<br>
&nbsp;&nbsp;&nbsp; A maximum of 16 communications ports are supported.&nbsp; </p><b>&nbsp;Task </b>

<table border=1 cellspacing=0 cellpadding=0 width=697 class="text" style="border-collapse: collapse" bordercolor="#000000">
 <tr>
  <td width="6%">
  <b>&nbsp;40</b></td>
  <td width="94%">
  &nbsp;Initialize communications port. This must be called once for each port before any other serial I/O function.<br>
&nbsp;The port defaults to 9600 baud, 8 data bits, no parity, one stop bit.<br>
&nbsp; Pre:<br>
&nbsp;&nbsp;&nbsp; High 16 bits of D0 contain port identifier 
	(PID), (0 through 15). The PID is used to identify<br>
&nbsp;&nbsp;&nbsp; the port in all other serial I/O tasks. It is not used to 
	specify the COM port number,<br>
&nbsp;&nbsp;&nbsp; (i.e. A PID of 4 does not mean the same thing as COM4)<br>
&nbsp;&nbsp;&nbsp; (A1) address of serial port name as null terminated string (e.g. 
	PORT&nbsp;&nbsp; DC.B&nbsp; 'COM4',0)<br>
&nbsp; Post:<br>
&nbsp;&nbsp;&nbsp; D0.W is 0 on success, 1 on invalid PID, 2 on error<p>Example:
	<span LANG="EN"><font SIZE="2">
	<p class="sourcecode" style="margin-top: 0; margin-bottom: 0">
	; initialize serial port<br>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; move.l&nbsp; 
	#1&lt;&lt;16+40,d0&nbsp; ; PID 1, task 40<br>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lea&nbsp;&nbsp;&nbsp;&nbsp; 
	PORT,A1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
	; name of port<br>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trap&nbsp;&nbsp;&nbsp;#15 
	</p></font>
	<p>
	&nbsp;Visit <a target="_blank" href="http://www.EASy68K.com">www.EASy68K.com</a> 
	for examples.</p></span></td>
 </tr>
 <tr>
  <td width="6%">
  <b>&nbsp;41</b></td>
  <td width="94%">
  &nbsp;Set port parameters.<br>
&nbsp; Pre:<br>
&nbsp;&nbsp;&nbsp; High 16 bits of D0 contain port identifier 
	(PID)<br>
&nbsp;&nbsp;&nbsp; D1.L<br>
&nbsp;&nbsp;&nbsp; Bits 0-7 (D1.B)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Baud rate: 0=9600(default), 
	1=110, 2=300, 3=600, 4=1200, 5=2400, 6=4800, 7=9600<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8=19200, 
	9=38400, 10=56000, 11=57600, 12=115200, 13=128000, 14=256000.<br>
&nbsp;&nbsp;&nbsp; Bits 8-9<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Parity: 0=no, 1=odd, 
	2=even, 3=mark<br>
&nbsp;&nbsp;&nbsp; Bits 10-11<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Number of data bits: 0=8 
	bits, 1=7 bits, 2=6 bits<br>
&nbsp;&nbsp;&nbsp; Bit 12<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stop bits: 0=1 stop bit, 
	1=2 stop bits<br>
&nbsp;&nbsp;&nbsp; The higher bits of D1.L are reserved for future use.<br>
&nbsp; Post:<br>
&nbsp;&nbsp;&nbsp; D0.W is 0 on success, 1 on invalid PID, 2 on error, 3 on port 
	not initialized<span LANG="EN"></span></td>
 </tr>
 <tr>
  <td width="6%">
  <b>&nbsp;42</b></td>
  <td width="94%">
  &nbsp;Receive string.<br>
&nbsp; Pre:<br>
&nbsp;&nbsp;&nbsp; High 16 bits of D0 contain port identifier 
	(PID)<br>
&nbsp;&nbsp;&nbsp; (A1) buffer address.<br>
&nbsp;&nbsp;&nbsp; D1.B max number of characters to receive. The port will wait 
	sufficient time for the requested number of bytes<br>
&nbsp;&nbsp;&nbsp; to be received. A timeout will occur if the number of bytes 
	received is less than the requested number. For<br>
&nbsp;&nbsp;&nbsp; faster response use a smaller number in D1.B.<br>
&nbsp; Post:<br>
&nbsp;&nbsp;&nbsp; D0.W is 0 on success, 1 on invalid PID, 2 on error, 3 on port 
	not initialized, 4 on timeout<br>
&nbsp;&nbsp;&nbsp; D1.B number of characters received.<br>
&nbsp;&nbsp;&nbsp; (A1) null terminated string of characters received.</td>
 </tr>
 <tr>
  <td>
  <b>&nbsp;43</b></td>
  <td width="94%">
  &nbsp;Send string.<br>
&nbsp; Pre:<br>
&nbsp;&nbsp;&nbsp; High 16 bits of D0 contain port identifier 
	(PID)<br>
&nbsp;&nbsp;&nbsp; (A1) buffer address.<br>
&nbsp;&nbsp;&nbsp; D1.B number of characters to send. The port will wait 
	sufficient time for the specified number of bytes<br>
&nbsp;&nbsp;&nbsp; to be sent. A timeout will occur if the number of bytes sent 
	is less than the requested number.<br>
&nbsp; Post:<br>
&nbsp;&nbsp;&nbsp; D0.W is 0 on success, 1 on invalid PID, 2 on error, 3 on port 
	not initialized, 4 on timeout<br>
&nbsp;&nbsp;&nbsp; D1.B number of characters sent.</td>
 </tr>
 </table>
<p></p>
</body>
</html>
